package com.example.cargroup.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.cargroup.R;
import com.example.cargroup.data.entity.CarEntity;
import com.example.loadimage.LoadImage;

import org.jetbrains.annotations.NotNull;

public class CarAdapter extends BaseQuickAdapter<CarEntity.DataBean, BaseViewHolder> {
    public CarAdapter() {
        super(R.layout.item_cat);
        addChildClickViewIds(R.id.car_item_radio,R.id.car_item_left,R.id.car_item_right);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, CarEntity.DataBean dataBean) {
        baseViewHolder.setText(R.id.car_item_title, dataBean.getGoods_desc());
        baseViewHolder.setText(R.id.car_item_dec,dataBean.getGoods_sku());
        baseViewHolder.setText(R.id.car_item_price,"￥"+dataBean.getGoods_price());
        baseViewHolder.setText(R.id.car_item_num,""+dataBean.getGoods_count());
        ImageView img = baseViewHolder.getView(R.id.car_item_img);
        LoadImage.loadImg(dataBean.getGoods_icon(), img);
        RadioButton radio = baseViewHolder.getView(R.id.car_item_radio);
        radio.setChecked(dataBean.selFalg);
        if (dataBean.edtFlag){
            radio.setVisibility(View.VISIBLE);
        }else {
            radio.setVisibility(View.GONE);
        }
    }
}
